package com.bootssm.service.impl;

import com.bootssm.dao.BookMapper;
import com.bootssm.pojo.Book;
import com.bootssm.pojo.BookVO;
import com.bootssm.service.BookService;
import com.bootssm.utils.IdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class BookServiceImpl implements BookService {

    @Autowired
    BookMapper bookMapper;
    @Override
    public List<Book> findAll(BookVO bookVO) {
        return bookMapper.findAll(bookVO);
    }

    @Override
    public Integer getCount(BookVO bookVO) {
        return bookMapper.getCount(bookVO);
    }
    @Autowired
    IdWorker idWorker;
    @Override
    public void save(Book book) {
        book.setBookId(idWorker.nextId()+"");
        bookMapper.save(book);
    }

    @Override
    public void delete(String bookId) {
        bookMapper.delete(bookId);
    }

    @Override
    public Book findById(String bookId) {
        return bookMapper.findById(bookId);
    }

    @Override
    public void update(Book book) {
        bookMapper.update(book);
    }
}
